package template

import (
	"math/rand"
	"strconv"
	"utilx/logx"
)

type EmailMember struct {
	OtpMember
}

func (s *EmailMember) genRandomOTP(len int) string {
	randomOTP := strconv.Itoa(int(rand.Intn(len)))
	logx.Debugf("EMAIL: generating random OtpArgs %s\n", randomOTP)
	return randomOTP
}

func (s *EmailMember) saveOTPCache(otp string) {
	logx.Warnf("EMAIL: saving OtpArgs: %s to cache\n", otp)
}

func (s *EmailMember) getMessage(otp string) string {
	return "EMAIL OTP for login is " + otp
}

func (s *EmailMember) sendNotification(message string) error {
	logx.ErrorLf("EMAIL: sending email: %s\n", message)
	return nil
}

type EmailArgs struct {
	OtpArgs
}

func (s *EmailArgs) genRandomOTP(len int) string {
	randomOTP := strconv.Itoa(int(rand.Intn(len)))
	logx.Debugf("EMAIL: generating random OtpArgs %s\n", randomOTP)
	return randomOTP
}

func (s *EmailArgs) saveOTPCache(otp string) {
	logx.Warnf("EMAIL: saving OtpArgs: %s to cache\n", otp)
}

func (s *EmailArgs) getMessage(otp string) string {
	return "EMAIL OTP for login is " + otp
}

func (s *EmailArgs) sendNotification(message string) error {
	logx.ErrorLf("EMAIL: sending email: %s\n", message)
	return nil
}
